﻿using System;
using Iesi.Collections.Generic;

namespace Family.Core.Model
{
    public class Product : EntityWithTypeId<Int32>
    {
        public virtual String Name { get; set; }

        public virtual Category Category { get; protected set; }

        public virtual ISet<OrderItem> OrderItems { get; protected set; }

        protected Product()
        {
            OrderItems = new HashedSet<OrderItem>();
        }

        public Product(Category category)
            : this()
        {
            Check.Require(category != null, new ArgumentNullException("Product .ctor", "parameter is null"));
            category.Products.Add(this);
            Category = category;
        }
    }
}
